<template>
  <div>
        <div class="layout-main">  
            <el-form ref="shopWx" label-position="right" label-width="140px" :model="shopWx" :roles="roles">
                <input type="hidden" :model="shopWx.id" />
                <el-form-item label="企业微信应用ID" prop="workAppId">
                    <el-input size="small" v-model="shopWx.workAppId" placeholder="AppId" style="width: 240px" />
                </el-form-item>
                <el-form-item label="企业微信应用密钥" prop="workAppSecret">
                    <el-input size="small" v-model="shopWx.workAppSecret" placeholder="workAppSecret" style="width: 240px" />
                </el-form-item>
                 <el-form-item label="企业微信企业ID" prop="workCropId">
                    <el-input size="small" v-model="shopWx.workCropId" placeholder="workCropId" style="width: 240px" />
                </el-form-item>
            </el-form>
            <div>
                <el-button size="small" @click="cancel">取消</el-button>
                <el-button size="small" type="primary" :loading="modalLoading" @click="ok">确定</el-button>
            </div>
        </div>
    </div>
</template>
<script>
import api from '@/api/api'
export default {
    name: 'ShopWx',
    data() {
        return {
            loading: false,
            modalLoading: false,

            others: {

            },
            shopWx: {

            },
            roles: [],
            shopWxId: null
        };
    },
    mounted: function() {
        this.getDetail();

    },
    methods: {

        getDetail: function() {

            var me = this;
            me.showLoading();
            me.$http.post("/sys/shopwx/get.action").then(response => {


                if (response.status == 0) {

                    me.shopWx = response.obj;

                }
                me.hideLoading();
            }, response => {
                me.hideLoading();
            });
        },
        ok: function() {
            var ok = false;
            this.$refs['shopWx'].validate((valid) => {
                ok = valid;
                if (valid) {

                } else {
                    this.errorMessage('请认真填写数据');
                }
            })
            if (!ok) return;
            var me = this;

            me.modalLoading = true;
            me.$http.post("/sys/shopwx/doSave.action", me.shopWx).then(response => {

                if (response.status == 0) {
                    me.successMessage("保存成功！");

                    me.modalEdit = false;

                } else {
                    me.errorMessage( response.info);
                }
                me.modalLoading = false;
            }, response => {
                me.modalLoading = false;
            });
        },
        cancel: function() {

            this.getDetail();

        }
    }
}
</script>
<style scoped>
</style>